package function

case class CaseTest(name:String,age:Int){
  println("初始构造："+name+age)
  /**
   * 样例类默认生成伴生对象和伴生类、
   */
  def this(name:String){
    this("张三",19)
    println(name)
  }
  def test(name:String,age:Int): String ={
    println(name+","+age)
    name+","+age
  }
}
object CaseTest{
  def main(args: Array[String]): Unit = {
    val test = new CaseTest("alice",18)
    val test1=new CaseTest("nx")
    val str: String = test  match {
      case CaseTest("alice", 18) => "alice,18"
      case _ => "Else"
    }
    println(str)
  }
}